import sq3 from 'sqlite3'

var dbPath = 'data.sqlite3'

const sqlite3 = sq3.verbose()
const db = new sqlite3.Database(dbPath)
db.serialize(() => {
  console.log('db.run')
  db.run(`CREATE TABLE IF NOT EXISTS activity (
    id          INTEGER  PRIMARY KEY AUTOINCREMENT,
    showid      STRING,
    actname     STRING,
    actdate     DATE,
    content     STRING,
    custinfo    STRING,
    custsex     STRING,
    custnum     STRING,
    address     STRING,
    startdate   DATETIME,
    enddate     DATETIME,
    owner       STRING,
    ownersex    STRING,
    ownernum    STRING,
    state       STRING,
    feedback    STRING,
    cricle      STRING,
    peoplecount STRING
    )`, err => {
    console.log(err)
  })

  db.run(`CREATE TABLE IF NOT EXISTS staff (
    id   INTEGER PRIMARY KEY AUTOINCREMENT,
    info STRING,
    sex  STRING,
    num  STRING
    )`, err => {
    console.log(err)
  })

  db.run(`CREATE TABLE IF NOT EXISTS customer (
    id      INTEGER PRIMARY KEY AUTOINCREMENT,
    info    STRING,
    sex     STRING,
    num     STRING,
    entertainers STRING
    )`, err => {
    console.log(err)
  })

  db.run(`CREATE TABLE IF NOT EXISTS owner (
    id      INTEGER PRIMARY KEY AUTOINCREMENT,
    info    STRING,
    sex     STRING,
    num     STRING,
    entertainers STRING
    )`, err => {
    console.log(err)
  })

  db.run(`CREATE TABLE IF NOT EXISTS waiguan (
    id      INTEGER PRIMARY KEY AUTOINCREMENT,
    name    STRING,
    zhuanli     STRING
    )`, err => {
    console.log(err)
  })
})

export default db
